package com.jxd.service.impl;

import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;

import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.jxd.config.HbaseConfig;
import com.jxd.entity.MesHead;
import com.jxd.hbase.utils.HBaseUtils;
import com.jxd.hbase.utils.QurryTableUntil;
import com.jxd.hbase.utils.UpdateSendDeviceName;
import com.jxd.model.EventRecord;
import com.jxd.model.ModelTotal;
import com.jxd.repositories.MesHeadRepositories;
import com.jxd.service.EventRecordService;
import com.jxd.service.ModelTotalMapperService;
import com.jxd.service.ShipInformationService;
import com.jxd.service.TimeStaticService;
@Service
public class TimeStaticServiceImpl implements TimeStaticService {
	
	@Value("${hbase.bwcontent.tablename}")
	private String bwContentTableName;
	
	@Autowired
    HbaseConfig hbaseConfig;
	
	@Autowired
    @Qualifier("mesHeadRepositories")
    MesHeadRepositories mesHeadRepositories;
	
	@Autowired
    @Qualifier("getHtableByMesHead")
    HTable mesHeadClient;
	
    @Autowired
    @Qualifier("getHtableByMesContent")
    HTable mesContentClient;
    
    @Autowired
    ShipInformationService shipInformationService;
    
    @Autowired
    ModelTotalMapperService modelTotalMapperService;
    
    @Autowired
    EventRecordService eventRecordService;

    @Autowired
    UpdateSendDeviceName updatedevicename;
    
    @Autowired
    QurryTableUntil qurryTableUntil;
	
	public List<MesHead> getAllMesHead(String fileName, String mesId, String shipId) {
		List<MesHead> mesHeads = mesHeadRepositories.findAllByFileNameAndMesIdAndShipId(fileName, mesId, shipId ,Sort.by(Sort.Order.asc("mesDate")));
		return mesHeads;
	}

	public List<ModelTotal> getAllModelTotal(List<MesHead> allMesHeads,Connection connection) { 
		List<ModelTotal> modelTotals = new ArrayList<ModelTotal>();
		List<String> sendDevices = new ArrayList<String>();
		String strDateFormat = "yyyy-MM-dd HH:mm:ss";
        SimpleDateFormat format = new SimpleDateFormat(strDateFormat);
		//获取所有模块
		for(int i=0;i<allMesHeads.size();i++) {
			String sendDevice = allMesHeads.get(i).getSendDevice();
			if(!sendDevices.contains(sendDevice)) {
				sendDevices.add(sendDevice);
			}
		}
		for(int j=0;j<sendDevices.size();j++) {
			//获取所有同设备的41008报文
			List<MesHead> unitMesHeads = new ArrayList<MesHead>();
			for(int k=0;k<allMesHeads.size();k++) {
				if(allMesHeads.get(k).getSendDevice().equals(sendDevices.get(j))) {
					unitMesHeads.add(allMesHeads.get(k));
				}
			}
			
			//同发控下所有单元
			List<ModelTotal> unitModelTotals = new ArrayList<ModelTotal>();

			//获取设备ID和文件名称
			String shipName = unitMesHeads.get(0).getShipId();
			String shipId = shipInformationService.selectbyXtbh(shipName);
			String filename = unitMesHeads.get(0).getFileName();
			//获取文件时间
			String filedate = unitMesHeads.get(0).getMesDate().substring(0,10).replace("/", "-");
			//获取有发射的单元
			List<EventRecord> launchRecords = eventRecordService.selectByUnitIdAndFileName(shipId, filename);
			List<String> lauchunitnames = new ArrayList<String>();
			//得到有发射的ModelTotal
			for(int i = 0;i<launchRecords.size();i++) {
				String launchunitname = launchRecords.get(i).getUnitname();
				if(!lauchunitnames.contains(launchunitname)) {
					lauchunitnames.add(launchunitname);
					ModelTotal lauchUnit = new ModelTotal();
					lauchUnit.setSbid(shipId);
					lauchUnit.setFiledate(filedate);
					lauchUnit.setUnitid(launchunitname);
					unitModelTotals.add(lauchUnit);
				}
				
			}
			
			
			try {
				List<String> moderowkeys = new ArrayList<String>();
				for(int i=0;i<unitMesHeads.size();i++) {
					String modeRowkey = unitMesHeads.get(i).getMesSignId()+"-2";
					moderowkeys.add(modeRowkey);
				}
				List<String> modes = qurryTableUntil.qurryBwContentVal(moderowkeys, bwContentTableName,connection);
				//获取开始时的模式
				String firstmode = modes.get(0);
				
				//获取总时长
				List<MesHead> useTimeMesHeads = mesHeadRepositories.findAllByFileNameAndMesIdAndShipIdAndSendDevice(filename, "49168", shipName,unitMesHeads.get(0).getSendDevice());
                long[] useTimes = new long[useTimeMesHeads.size()];
                for(int j1=0;j1<useTimeMesHeads.size();j1++) {
                	String time = useTimeMesHeads.get(j1).getMesDate().substring(0,11).replace("/", "-")+useTimeMesHeads.get(j1).getMesTime().substring(0,8);
                	Date times = format.parse(time);
                	long timenum = times.getTime();
                	useTimes[j1] = timenum;
                }
                Arrays.sort(useTimes);
                double modeltime = 0;
                for(int i=1;i<useTimes.length;i++) {
                	if((useTimes[i]-useTimes[i-1])/1000.0<60.0) {
                		modeltime = modeltime + (useTimes[i]-useTimes[i-1])/1000.0;
                	}
                }
                modeltime = modeltime/60;

                
				double zzomodeltime = 0;
				double xlmodeltime = 0;
				double whmodeltime = 0;
				double djmodeltime = 0;
				int zzomodelnum = 0;
				int xlmodelnum = 0;
				int whmodelnum = 0;
				int djmodelnum = 0;
				if("0001".equals(firstmode)) {
					zzomodelnum += 1;
				}else if("0004".equals(firstmode)) {
					xlmodelnum += 1;
				}else if("0000".equals(firstmode)) {
					djmodelnum += 1;
				}else if("0002".equals(firstmode)) {
					whmodelnum += 1;
				}
				String starttime = unitMesHeads.get(0).getMesDate().substring(0,11).replace("/", "-")+unitMesHeads.get(0).getMesTime().substring(0,8);
				Date starttimenum = format.parse(starttime);
				for(int t=1;t<modes.size();t++) {
					String val = modes.get(t);
					if(!val.equals(firstmode)) {
						if("0001".equals(val)) {
							zzomodelnum = zzomodelnum+1;
						}else if("0004".equals(val)) {
							xlmodelnum = xlmodelnum+1;
						}else if("0000".equals(val)) {
							djmodelnum = djmodelnum+1;
						}else if("0002".equals(val)) {
							whmodelnum = whmodelnum+1;
						}
					}
					String endtime = unitMesHeads.get(t).getMesDate().substring(0,11).replace("/", "-")+unitMesHeads.get(t).getMesTime().substring(0,8);
					Date endtimenum = format.parse(endtime);
					if((endtimenum.getTime()-starttimenum.getTime())/1000.0 < 60.0) {
						if("0001".equals(firstmode)) {
							zzomodeltime = zzomodeltime+(endtimenum.getTime()-starttimenum.getTime())/60000.0;
						}else if("0004".equals(firstmode)) {
							xlmodeltime = xlmodeltime+(endtimenum.getTime()-starttimenum.getTime())/60000.0;
						}else if("0000".equals(firstmode)) {
							djmodeltime = djmodeltime+(endtimenum.getTime()-starttimenum.getTime())/60000.0;
						}else if("0002".equals(firstmode)) {
							whmodeltime = whmodeltime+(endtimenum.getTime()-starttimenum.getTime())/60000.0;
						}
					}
					
					firstmode = val;
					starttime = endtime;
					starttimenum = endtimenum;
				}
				
				for(int i=0;i<unitModelTotals.size();i++) {
					//给发射单元的各个时间赋值
					unitModelTotals.get(i).setZzomodeltime(String.valueOf(zzomodeltime));
					unitModelTotals.get(i).setXlmodeltime(String.valueOf(xlmodeltime));
					unitModelTotals.get(i).setWhmodeltime(String.valueOf(whmodeltime));
					unitModelTotals.get(i).setDjmodeltime(String.valueOf(djmodeltime));
					unitModelTotals.get(i).setZzomodelnum(String.valueOf(zzomodelnum));
					unitModelTotals.get(i).setXlmodelnum(String.valueOf(xlmodelnum));
					unitModelTotals.get(i).setWhmodelnum(String.valueOf(whmodelnum));
					unitModelTotals.get(i).setDjmodelnum(String.valueOf(djmodelnum));
					unitModelTotals.get(i).setModeltime(String.valueOf(modeltime));
					//更新流程表中的训练时间和使用时长
					EventRecord eventRecord = new EventRecord();
					eventRecord.setXltime(xlmodeltime);
					eventRecord.setZztime(zzomodeltime);
					eventRecord.setFilename(filename);
					eventRecord.setUnitid(shipId);
					eventRecord.setUnitname(unitModelTotals.get(i).getUnitid());
					eventRecordService.updateXlTime(eventRecord);
				}
				
				//所有没发射的单元
				if(lauchunitnames.size()>0) {
					String firsttwo = lauchunitnames.get(0).substring(0,2);
					for(int i=1;i<9;i++) {
						String nolaunchunitname = firsttwo+i+"0";
						if(!lauchunitnames.contains(nolaunchunitname)) {
							ModelTotal nolaunchmodeltotal = new ModelTotal();
							nolaunchmodeltotal.setSbid(shipId);
							nolaunchmodeltotal.setUnitid(nolaunchunitname);
							nolaunchmodeltotal.setFiledate(filedate);
							nolaunchmodeltotal.setZzomodeltime("0");
							nolaunchmodeltotal.setZzomodelnum("0");
							nolaunchmodeltotal.setXlmodeltime("0");
							nolaunchmodeltotal.setXlmodelnum("0");
							nolaunchmodeltotal.setWhmodeltime(String.valueOf(whmodeltime));
							nolaunchmodeltotal.setWhmodelnum(String.valueOf(whmodelnum));
							nolaunchmodeltotal.setDjmodeltime(String.valueOf(modeltime-whmodeltime));
							nolaunchmodeltotal.setDjmodelnum(String.valueOf(djmodelnum+xlmodelnum+zzomodelnum));
							nolaunchmodeltotal.setModeltime(String.valueOf(modeltime));
							unitModelTotals.add(nolaunchmodeltotal);
						}
					}
					
				}else {
					String firsttwo = updatedevicename.updateSendDeviceName(shipName, unitMesHeads.get(0).getSendDevice());
					for(int i=1;i<9;i++) {
						String nolaunchunitname = firsttwo+i+"0";
						ModelTotal nolaunchmodeltotal = new ModelTotal();
						nolaunchmodeltotal.setSbid(shipId);
						nolaunchmodeltotal.setUnitid(nolaunchunitname);
						nolaunchmodeltotal.setFiledate(filedate);
						nolaunchmodeltotal.setZzomodeltime("0");
						nolaunchmodeltotal.setZzomodelnum("0");
						nolaunchmodeltotal.setXlmodeltime("0");
						nolaunchmodeltotal.setXlmodelnum("0");
						nolaunchmodeltotal.setWhmodeltime(String.valueOf(whmodeltime));
						nolaunchmodeltotal.setWhmodelnum(String.valueOf(whmodelnum));
						nolaunchmodeltotal.setDjmodeltime(String.valueOf(modeltime-whmodeltime));
						nolaunchmodeltotal.setDjmodelnum(String.valueOf(djmodelnum));
						nolaunchmodeltotal.setModeltime(String.valueOf(modeltime));
						unitModelTotals.add(nolaunchmodeltotal);
					}
				}
				
				modelTotals.addAll(unitModelTotals);
				
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} finally {
                IOUtils.closeStream(mesContentClient);
            }
				
		}
		
		return modelTotals;
	}
	
	public List<ModelTotal> getModelTotals(String filename, String shipname) throws IOException, ParseException{
		String strDateFormat = "yyyy-MM-dd HH:mm:ss";
        SimpleDateFormat format = new SimpleDateFormat(strDateFormat);
        
		List<ModelTotal> modelTotals = new ArrayList<ModelTotal>();
		String baseRowKey = "1,"+filename+","+shipname+",";
		//获取所有41008报文
		Iterator<Result> iterator = HBaseUtils.getLineByStartKeyAndEndKey(baseRowKey + "41008", baseRowKey + "41009");
		
		//获取所有模块（同发送设备代表同模块）
		List<String> sendDevices = new ArrayList<String>();
		while(iterator.hasNext()) {
			Result rs = iterator.next();
			String sendDevice = Bytes.toString(rs.getValue(Bytes.toBytes(HBaseUtils.FAMILY), Bytes.toBytes(HBaseUtils.SEND_DEVICE))).replace("'", "");
			if(!sendDevices.contains(sendDevice)) {
				sendDevices.add(sendDevice);
			}
		}
		
		//每个模块的modeltotals
		for(int i=0;i<sendDevices.size();i++) {
			//获取所有该设备的41008报文
			List<Result> rsSendDevice = new ArrayList<Result>();
			List<String> modes = new ArrayList<String>();
			while(iterator.hasNext()) {
				Result rs = iterator.next();
				String sendDevice = Bytes.toString(rs.getValue(Bytes.toBytes(HBaseUtils.FAMILY), Bytes.toBytes(HBaseUtils.SEND_DEVICE))).replace("'", "");
				if(sendDevice.equals(sendDevices.get(i))) {
					rsSendDevice.add(rs);
					//获取该设备所有报文的模式
					String mode = Bytes.toString(rs.getValue(Bytes.toBytes(HBaseUtils.FAMILY), Bytes.toBytes("2"))).replace("'", "");
					modes.add(mode);
				}
			}
			
			//同发控下所有单元
			List<ModelTotal> unitModelTotals = new ArrayList<ModelTotal>();

			//获取文件时间
			String filedate = Bytes.toString(rsSendDevice.get(0).getValue(Bytes.toBytes(HBaseUtils.FAMILY), Bytes.toBytes(HBaseUtils.MES_DATE))).replace("'", "").substring(0,10);
			//获取设备ID
			String shipId = shipInformationService.selectbyXtbh(shipname);
			
			//获取整个设备有发射的记录
			List<EventRecord> launchRecords = eventRecordService.selectByUnitIdAndFileName(shipId, filename);
			//获取该发送设备对应的单元号的前两位
			String firsttwo = updatedevicename.updateSendDeviceName(shipname, sendDevices.get(i));
			//整个设备所有发射单元的单元号
			List<String> lauchunitnames = new ArrayList<String>();
			for(int j = 0;j<launchRecords.size();j++) {
				String launchunitname = launchRecords.get(j).getUnitname();
				//筛选出该发送设备的发射单元
				if(launchunitname.substring(0,2).equals(firsttwo)) {
					//向unitModelTotals中添加有发射的单元的ModelTotal
					if(!lauchunitnames.contains(launchunitname)) {
						lauchunitnames.add(launchunitname);
						ModelTotal lauchUnit = new ModelTotal();
						lauchUnit.setSbid(shipId);
						lauchUnit.setFiledate(filedate);
						lauchUnit.setUnitid(launchunitname);
						unitModelTotals.add(lauchUnit);
					}
				}
			}
			
			//获取总时长
			//获取所有49168报文
			Iterator<Result> modeltimeIterator = HBaseUtils.getLineByStartKeyAndEndKey(baseRowKey + "49168", baseRowKey + "49169");
			List<String> modeltimenum = new ArrayList<String>();
			while(modeltimeIterator.hasNext()) {
				Result modeltimers = modeltimeIterator.next();
				String mtsendDevice = Bytes.toString(modeltimers.getValue(Bytes.toBytes(HBaseUtils.FAMILY), Bytes.toBytes(HBaseUtils.SEND_DEVICE))).replace("'", "");
				//获取相同设备的49168报文的时间
				if(mtsendDevice.equals(sendDevices.get(i))) {
					String time = Bytes.toString(modeltimers.getValue(Bytes.toBytes(HBaseUtils.FAMILY), Bytes.toBytes(HBaseUtils.MES_DATE))).replace("'", "").substring(0,11).replace("/", "-")
							+Bytes.toString(modeltimers.getValue(Bytes.toBytes(HBaseUtils.FAMILY), Bytes.toBytes(HBaseUtils.MES_TIME))).replace("'", "").substring(0,8);
                	modeltimenum.add(time);
				}
			}
			//计算总时长
			double modeltime = 0;
            for(int j=1;j<modeltimenum.size();j++) {
            	String sttime = modeltimenum.get(j);
            	String endtime = modeltimenum.get(j-1);
            	Date sttimes = format.parse(sttime);
            	long sttimenum = sttimes.getTime();
            	Date endtimes = format.parse(sttime);
            	long endtimenum = endtimes.getTime();
            	if((sttimenum-endtimenum)/1000.0<60.0) {
            		modeltime = modeltime + (sttimenum-endtimenum)/1000.0;
            	}
            }
            modeltime = modeltime/60;
			
            //获取开始时的模式
			String firstmode = modes.get(0);
			double zzomodeltime = 0;
			double xlmodeltime = 0;
			double whmodeltime = 0;
			double djmodeltime = 0;
			int zzomodelnum = 0;
			int xlmodelnum = 0;
			int whmodelnum = 0;
			int djmodelnum = 0;
			if("0001".equals(firstmode)) {
				zzomodelnum += 1;
			}else if("0004".equals(firstmode)) {
				xlmodelnum += 1;
			}else if("0000".equals(firstmode)) {
				djmodelnum += 1;
			}else if("0002".equals(firstmode)) {
				whmodelnum += 1;
			}
			String starttime = Bytes.toString(rsSendDevice.get(0).getValue(Bytes.toBytes(HBaseUtils.FAMILY), Bytes.toBytes(HBaseUtils.MES_DATE))).replace("'", "").substring(0,11).replace("/", "-")
					+Bytes.toString(rsSendDevice.get(0).getValue(Bytes.toBytes(HBaseUtils.FAMILY), Bytes.toBytes(HBaseUtils.MES_TIME))).replace("'", "").substring(0,8);
			Date starttimenum = format.parse(starttime);
			//计算各模式时间和次数
			for(int t=1;t<modes.size();t++) {
				String val = modes.get(t);
				if(!val.equals(firstmode)) {
					if("0001".equals(val)) {
						zzomodelnum = zzomodelnum+1;
					}else if("0004".equals(val)) {
						xlmodelnum = xlmodelnum+1;
					}else if("0000".equals(val)) {
						djmodelnum = djmodelnum+1;
					}else if("0002".equals(val)) {
						whmodelnum = whmodelnum+1;
					}
				}
				String endtime = Bytes.toString(rsSendDevice.get(t).getValue(Bytes.toBytes(HBaseUtils.FAMILY), Bytes.toBytes(HBaseUtils.MES_DATE))).replace("'", "").substring(0,11).replace("/", "-")
						+Bytes.toString(rsSendDevice.get(t).getValue(Bytes.toBytes(HBaseUtils.FAMILY), Bytes.toBytes(HBaseUtils.MES_TIME))).replace("'", "").substring(0,8);
				Date endtimenum = format.parse(endtime);
				if((endtimenum.getTime()-starttimenum.getTime())/1000.0 < 60.0) {
					if("0001".equals(firstmode)) {
						zzomodeltime = zzomodeltime+(endtimenum.getTime()-starttimenum.getTime())/60000.0;
					}else if("0004".equals(firstmode)) {
						xlmodeltime = xlmodeltime+(endtimenum.getTime()-starttimenum.getTime())/60000.0;
					}else if("0000".equals(firstmode)) {
						djmodeltime = djmodeltime+(endtimenum.getTime()-starttimenum.getTime())/60000.0;
					}else if("0002".equals(firstmode)) {
						whmodeltime = whmodeltime+(endtimenum.getTime()-starttimenum.getTime())/60000.0;
					}
				}
				
				firstmode = val;
				starttimenum = endtimenum;
			}
			
			for(int j=0;j<unitModelTotals.size();j++) {
				//给发射单元的各个时间赋值
				unitModelTotals.get(j).setZzomodeltime(String.valueOf(zzomodeltime));
				unitModelTotals.get(j).setXlmodeltime(String.valueOf(xlmodeltime));
				unitModelTotals.get(j).setWhmodeltime(String.valueOf(whmodeltime));
				unitModelTotals.get(j).setDjmodeltime(String.valueOf(djmodeltime));
				unitModelTotals.get(j).setZzomodelnum(String.valueOf(zzomodelnum));
				unitModelTotals.get(j).setXlmodelnum(String.valueOf(xlmodelnum));
				unitModelTotals.get(j).setWhmodelnum(String.valueOf(whmodelnum));
				unitModelTotals.get(j).setDjmodelnum(String.valueOf(djmodelnum));
				unitModelTotals.get(j).setModeltime(String.valueOf(modeltime));
				unitModelTotals.get(j).setId(UUID.randomUUID().toString().replace("-", ""));
				//更新流程表中的训练时间和使用时长
				EventRecord eventRecord = new EventRecord();
				eventRecord.setXltime(xlmodeltime);
				eventRecord.setZztime(zzomodeltime);
				eventRecord.setFilename(filename);
				eventRecord.setUnitid(shipId);
				eventRecord.setUnitname(unitModelTotals.get(j).getUnitid());
				eventRecordService.updateXlTime(eventRecord);
			}
			
			//所有没发射的单元
			//同发控下有发射单元
			if(lauchunitnames.size()>0) {
				for(int j=1;j<9;j++) {
					String nolaunchunitname = firsttwo+j+"0";
					if(!lauchunitnames.contains(nolaunchunitname)) {
						ModelTotal nolaunchmodeltotal = new ModelTotal();
						nolaunchmodeltotal.setSbid(shipId);
						nolaunchmodeltotal.setUnitid(nolaunchunitname);
						nolaunchmodeltotal.setFiledate(filedate);
						nolaunchmodeltotal.setZzomodeltime("0");
						nolaunchmodeltotal.setZzomodelnum("0");
						nolaunchmodeltotal.setXlmodeltime("0");
						nolaunchmodeltotal.setXlmodelnum("0");
						nolaunchmodeltotal.setWhmodeltime(String.valueOf(whmodeltime));
						nolaunchmodeltotal.setWhmodelnum(String.valueOf(whmodelnum));
						nolaunchmodeltotal.setDjmodeltime(String.valueOf(modeltime-whmodeltime));
						nolaunchmodeltotal.setDjmodelnum(String.valueOf(djmodelnum+xlmodelnum+zzomodelnum));
						nolaunchmodeltotal.setModeltime(String.valueOf(modeltime));
						nolaunchmodeltotal.setId(UUID.randomUUID().toString().replace("-", ""));
						unitModelTotals.add(nolaunchmodeltotal);
					}
				}
			}else { //同发控下没有发射单元
				for(int j=1;j<9;j++) {
					String nolaunchunitname = firsttwo+j+"0";
					ModelTotal nolaunchmodeltotal = new ModelTotal();
					nolaunchmodeltotal.setSbid(shipId);
					nolaunchmodeltotal.setUnitid(nolaunchunitname);
					nolaunchmodeltotal.setFiledate(filedate);
					nolaunchmodeltotal.setZzomodeltime("0");
					nolaunchmodeltotal.setZzomodelnum("0");
					nolaunchmodeltotal.setXlmodeltime("0");
					nolaunchmodeltotal.setXlmodelnum("0");
					nolaunchmodeltotal.setWhmodeltime(String.valueOf(whmodeltime));
					nolaunchmodeltotal.setWhmodelnum(String.valueOf(whmodelnum));
					nolaunchmodeltotal.setDjmodeltime(String.valueOf(modeltime-whmodeltime));
					nolaunchmodeltotal.setDjmodelnum(String.valueOf(djmodelnum));
					nolaunchmodeltotal.setModeltime(String.valueOf(modeltime));
					nolaunchmodeltotal.setId(UUID.randomUUID().toString().replace("-", ""));
					unitModelTotals.add(nolaunchmodeltotal);
				}
			}
			
			modelTotals.addAll(unitModelTotals);
			
		}
		return modelTotals;
	}
	
	public void insertModelTotal(List<ModelTotal> modelTotals) {
			modelTotalMapperService.insertList(modelTotals);
	}
	
	
}
